package com.cr.business.service.impl;

import com.cr.business.domain.TbRegion;
import com.cr.business.domain.vo.AppRegionData;
import com.cr.business.mapper.TbRegionMapper;
import com.cr.business.service.TbRegionService;
import com.cr.common.utils.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TbRegionServiceImpl implements TbRegionService {

    @Resource
    private TbRegionMapper tbRegionMapper;

    @Override
    public String getRegionNameByCode(String code) {
        if(StringUtils.isBlank(code)) {
            return "";
        }
        TbRegion tbRegion = tbRegionMapper.selectTbRegionByAgencyId(code);
        if(tbRegion != null) {
            return tbRegion.getName();
        }
        return "";
    }

    @Override
    public List<AppRegionData> getRegionDatas(String parent) {
        return tbRegionMapper.selectTbRegionByParentCode(parent);
    }
}
